<?php


namespace app\admin\validate;


class Category extends BaseValidate
{
    protected $rule = [
        'id' => 'require|integer|gt:0',
        'name' => 'require|length:0,12|unique:category,name',
        'description' => 'length:0,255',
        'parent_id' => 'require|integer|egt:0|different:id',
        'img' => 'require',
    ];

    protected $message = [
        'id' => '商品分类id号必填,并且正整数',
        'name.require' => '分类名字必填',
        'name.length' => '分类名字在6到12个汉字',
        'name.unique' => '分类名字已存在',
        'description' => '分类描述不能超过255个字符',
        'parent_id' => '父级分类id号必填',
        'parent_id.different' => '父级分类id号不能与id号相同',
        'img.require' => '分类图片必填',
    ];

    protected $scene = [
        'save' => ['img', 'name', 'description', 'parent_id'],
        'update' => ['id', 'name', 'description', 'parent_id'],
        'delete' => ['id'],
        'read' => ['id']
    ];
}